package luj.tool.jnproxyan.proxy.network.socks.actor.root.message.request.init.add;

import luj.tool.jnproxyan.proxy.network.socks.actor.root.Socks5Actor;
import luj.tool.jnproxyan.proxy.network.socks.request.SocksRequest;
import org.springframework.stereotype.Component;

@Component
final class OnAddRequest implements Socks5Actor.Handler<AddRequestMsg> {

  @Override
  public void onHandle(Context ctx) {
    Socks5Actor self = ctx.getActorState(this);
    AddRequestMsg msg = ctx.getMessage(this);
    Long reqId = msg.reqId();

    SocksRequest req = new SocksRequest(reqId, msg.time(), msg.c2pConn(), msg.c2pConnV2());
    req.setStatus("#1:浏览器发起");

    self.getRequestMap().put(reqId, req);
  }
}
